package ee.siimkaspar.subjects.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@Entity
@Table(name = "user_account")
public class UserAccount implements Serializable, ModelInterface {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "user_account", unique = true, nullable = false)
	private Integer id;
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "subject_fk")
	private Employee employeeBySubjectFk; //employee who's account this is
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "subject_type_fk")
	private SubjectType subjectType; //always 3
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "created_by")
	private Employee employeeByCreatedBy; // who created this account?
	@Column(name = "username", length = 50)
	private String username;
	@Column(name = "passw", length = 300)
	private String passw;
	@Column(name = "status")
	private Integer status;
	@Temporal(TemporalType.DATE)
	@Column(name = "valid_from", length = 13)
	private Date validFrom;
	@Temporal(TemporalType.DATE)
	@Column(name = "valid_to", length = 13)
	private Date validTo;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created", length = 29)
	private Date created;
	@Column(name = "password_never_expires", length = 1)
	private String passwordNeverExpires;

	public UserAccount() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Employee getEmployeeBySubjectFk() {
		return this.employeeBySubjectFk;
	}

	public void setEmployeeBySubjectFk(Employee employeeBySubjectFk) {
		this.employeeBySubjectFk = employeeBySubjectFk;
	}

	public SubjectType getSubjectType() {
		return this.subjectType;
	}

	public void setSubjectType(SubjectType subjectType) {
		this.subjectType = subjectType;
	}

	public Employee getEmployeeByCreatedBy() {
		return this.employeeByCreatedBy;
	}

	public void setEmployeeByCreatedBy(Employee employeeByCreatedBy) {
		this.employeeByCreatedBy = employeeByCreatedBy;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassw() {
		return this.passw;
	}

	public void setPassw(String passw) {
		this.passw = passw;
	}

	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getValidFrom() {
		return this.validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	public Date getValidTo() {
		return this.validTo;
	}

	public void setValidTo(Date validTo) {
		this.validTo = validTo;
	}

	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getPasswordNeverExpires() {
		return this.passwordNeverExpires;
	}

	public void setPasswordNeverExpires(String passwordNeverExpires) {
		this.passwordNeverExpires = passwordNeverExpires;
	}
	@Override
	public boolean validate() {
		// TODO Auto-generated method stub
		return true;
	}
}
